#include <iostream>
using namespace std;


int main(){
	int n;
	cin>>n;
	int x[n],y[n],a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>a[i]>>b[i];
	}
	int ax,ay;
	cin>>ax>>ay;
	int ans=-1;
	for(int i=n-1;i>=0;i--){
		if(x[i] <= ax  &&  ax <= x[i]+a[i]  &&  y[i] <= ay  &&  ay <= y[i]+b[i]){
			ans = i+1;
			break;
		}
	}
	cout<<ans;
}
